package com.usian.search.controller;

import com.usian.api.search.SearchControllerApi;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.search.dto.UserSearchDto;
import com.usian.search.service.ApUserSearchService;
import com.usian.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Auther:ASS
 * @Date:2023/3/8 19:36
 */
@RestController
@RequestMapping("/api/v1/article/search")
public class SearchController implements SearchControllerApi {


    @Autowired
    private SearchService searchService;

    @Autowired
    private ApUserSearchService apUserSearchService;


    /**
     * 搜索文章
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/search")
    public ResponseResult search(@RequestBody UserSearchDto dto){
        return searchService.search(dto);
    }


    /**
     * 查询搜索记录
     * @param dto
     * @return
     */

    @Override
    @PostMapping("/load")
    public ResponseResult findSearch(@RequestBody UserSearchDto dto) {
        return apUserSearchService.findSearch(dto);
    }

    /**
     * 删除搜索记录
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/del")
    public ResponseResult deleteSearch(@RequestBody UserSearchDto dto) {
        return apUserSearchService.deleteSearch(dto);
    }
}
